<!--
 * @Author: Allen
 * @Date: 2021-03-25 14:50:21
 * @Description: 抱怨身处黑暗，不如提灯前行。愿你在自己存在的地方，成为一束光，照亮世界的一角
 * @LastEditTime: 2021-03-26 15:57:21
 * @LastEditors: Allen
 * @FilePath: \dmocdms_webend\src\components\QueryComponent\QueryComponentS.vue
 * @Additional: 附加类容
-->
<template>
  <el-table :data="partRepairList" border stripe @selection-change="repairTypeDelete">
    <el-table-column
      align="center"
      type="selection"
      width="40"
    ></el-table-column>
    <el-table-column prop="updateControlId" v-if="false"></el-table-column>
    <el-table-column
      label="序号"
      align="center"
      width="60"
      type="index"
    ></el-table-column>
    <el-table-column
      prop="partNo"
      align="center"
      label="备件编码"
    ></el-table-column>
    <el-table-column
      prop="partName"
      align="center"
      label="备件名称"
    ></el-table-column>
    <el-table-column prop="repairTypeCode" align="center" label="维修类型">
      <template slot-scope="scope">
        <el-select
          v-model="scope.row.repairTypeCode"
          placeholder="请选择"
          @change="repairTypeChange(scope)"
        >
          <el-option
            v-for="(item, index) in repairTypeArr"
            :key="index"
            :label="item.LOOKUP_VALUE_NAME"
            :value="item.LOOKUP_VALUE_CODE"
          >
          </el-option>
        </el-select>
      </template>
    </el-table-column>
    <el-table-column prop="payKind" align="center" label="付费性质">
      <template slot-scope="scope">
        <el-select
          v-model="scope.row.payKind"
          placeholder="请选择"
          @change="repairTypeChange(scope)"
        >
          <el-option
            v-for="(item, index) in payKindArr"
            :key="index"
            :label="item.LOOKUP_VALUE_NAME"
            :value="item.LOOKUP_VALUE_CODE"
          >
          </el-option>
        </el-select>
      </template>
    </el-table-column>
    <el-table-column prop="partQty" align="center" label="数量">
    </el-table-column>
    <el-table-column
      prop="partPrice"
      align="center"
      label="单价"
    ></el-table-column>
    <el-table-column
      prop="partAmount"
      align="center"
      label="费用合计"
    ></el-table-column>
    <el-table-column
      prop="retRepairTypeName"
      align="center"
      label="维修类别"
    ></el-table-column>
    <el-table-column
      prop="partDiscount"
      align="center"
      label="折扣率"
    ></el-table-column>
    <el-table-column
      prop="prePartAmount"
      align="center"
      label="费用预估"
    ></el-table-column>
    <el-table-column prop="isEntrustCode" align="center" label="是否委外">
      <template slot-scope="scope">
        <el-select v-model="scope.row.isEntrustCode" placeholder="请选择">
          <el-option label="是" value="1"> </el-option>
          <el-option label="否" value="0"> </el-option>
        </el-select>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import request from "@/utils/request.js";
export default {
  props: {},
  data() {
    return {
      isShow: true,
      partRepairList: [],
      retRepairArr: [],
      repairTypeArr: [],
      payKindArr: [],
    };
  },
  mounted() {
    this.partRepair();
  },
  methods: {
    partRepair() {
      request({
        url:
          "/mp/e3sh/aftersale/WorkOrderManagementService/repairPartList",
        method: "post",
        data: {
          repairOrderId: this.repairOrderId,
        },
      }).then((res) => {
        this.partRepairList = res.rows;
        console.log(res)
      });
    },
    changeShow() {
      this.isShow = !this.isShow;
    },
    repairTypeChange(e) {
      let index = e.$index;
      let repairPartId = this.partRepairList[index].repairPartId;
      let repairTypeCode = e.row.repairTypeCode;
      let payKind = e.row.payKind;
      let comboSaleCode = e.row.comboSaleCode;
      let isEntrustCode = e.row.isEntrustCode;
      let updateControlId = e.row.updateControlId;
      request({
        url: "/mp/e3sh/aftersale/WorkOrderManagementService/repairPartUpd",
        method: "post",
        data: {
          repairPartId: repairPartId,
          repairTypeCode: repairTypeCode,
          payKind: payKind,
          comboSaleCode: comboSaleCode,
          isEntrustCode: isEntrustCode,
          updateControlId: updateControlId,
        },
      }).then((res) => {
        res.result == 1 ? this.$message(res.msg) : this.$message("编辑失败");
      });
    },
    repairTypeDelete(val) {
      let list = [];
      val.map((item) => {
        list.push(item.repairPartId);
      });
      this.$emit("selectList", list);
    },
  },
};
</script>

<style lang="scss" scoped>
.query-comp {
  width: 100%;
  background-color: #fff;
  // &__header {
  .filter-container.filter-title {
    width: 160px;
    cursor: pointer;
  }
  // }
}
</style>